//
//  ViewController.swift
//  圆角动画
//
//  Created by app on 2017/4/14.
//  Copyright © 2017年 app. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

    var loginButton:UIButton!
    override func viewDidLoad() {
        super.viewDidLoad()
        
        loginButton = UIButton()
        loginButton.frame  = CGRect(x: 20, y: 230, width: view.frame.width - 40, height: 40)
        loginButton.backgroundColor = UIColor.red
        loginButton.setTitle("11", for: .normal)
        view.addSubview(loginButton)
    }
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        let animation = CABasicAnimation()
        animation.keyPath = "cornerRadius"
        animation.toValue = 15
        animation.duration = 2.0
        animation.fillMode = kCAFillModeForwards
        animation.isRemovedOnCompletion = false
        loginButton.layer.add(animation, forKey: nil)
        
    
    }


}

